import request from "@/utils/request";

export function getInfo(sid) {
  return request({
    url: "/api/user/mine",
    method: "post",
    data: {
      sid: sid,
    },
  });
}

export function logout() {
  return request({
    url: "/api/user/webLogout",
    method: "post",
  });
}

// 获取登录码
export function getCode(channel) {
  return request({
    url: "/api/v2/user/offiaccountLogin?channel=" + channel,
    method: "get",
  });
}
// 获取登录码
export function getMiniLoginScene() {
  return request({
    url: "/api/user/getMiniLoginScene",
    method: "post",
  });
}

// 获取登录二维码
export function getMiniQrCode(scene) {
  return request({
    url: "/api/user/getMiniQrCode?scene=" + scene,
    method: "get",
    responseType: "arraybuffer",
  });
}

// // 获取登录码
// export function getCode() {
//   return request({
//     url: '/api/system/getWxLoginCode',
//     method: 'post'
//   })
// }

// // 验证登录码
// export function verifyCode(code) {
//   return request({
//     url: '/api/system/wxLoginChecking',
//     method: 'post',
//     data: {
//       'code': code
//     }
//   })
// }

// 验证登录码
export function verifyCode(scene) {
  return request({
    url: "/api/user/miniLoginChecking?scene=" + scene,
    method: "get",
  });
}

// 验证手机号码
export function verifyPhone(phone) {
  return request({
    url: "/api/user/verifyUserPhone",
    method: "post",
    data: {
      phone: phone,
    },
  });
}

// 手机登录
export function phoneLogin(phone, pwd) {
  return request({
    url: "/api/user/phoneLogin",
    method: "post",
    data: {
      phone: phone,
      pwd: pwd,
    },
  });
}

// 用户名登录
export function usernameLogin(username, pwd) {
  return request({
    url: "/api/v2/user/usernameLogin",
    method: "post",
    data: {
      username: username,
      password: pwd,
    },
  });
}

// 手机绑定
export function phoneBind(data) {
  return request({
    url: "/api/user/bindPhone",
    method: "post",
    data,
  });
}

// 找回密码
export function returnPwd(phone, pwd, code) {
  return request({
    url: "/api/user/returnPwd",
    method: "post",
    data: {
      phone: phone,
      pwd: pwd,
      code: code,
    },
  });
}

// 发送短信验证码
export function sendSms(phone) {
  return request({
    url: "/api/user/sendPhoneCode",
    method: "post",
    data: {
      phone: phone,
    },
  });
}

// 获取我的收藏
export function myFavorite(data) {
  return request({
    url: "/api/user/myFavorite",
    method: "post",
    data,
  });
}

// 获取我上传的文档
export function myUploadFile(data) {
  return request({
    url: "/api/user/myUploadFile",
    method: "post",
    data,
  });
}

// 收藏
export function doFavorite(data) {
  return request({
    url: "/api/user/doFavorite",
    method: "post",
    data,
  });
}

//提建议
export function suggest(data) {
  return request({
    url: "/api/v2/feedback/submit",
    method: "post",
    data,
  });
}
//记录文件 下载浏览（某个用户）
export function recordFile(data) {
  return request({
    url: "/api/ffile/recordFile",
    method: "post",
    data,
  });
}

//记录文件的被下载次数
export function apiAddDownloadCount(data) {
  return request({
    url: "/api/ffile/apiAddDownloadCount",
    method: "post",
    data,
  });
}
